package com.qaml.mes.device.controller;

import com.earth.output.OutputMessage;
import com.earth.page.PageResponse;
import com.qaml.mes.device.api.DayOffService;
import com.qaml.mes.device.dto.dayoff.DayOffIdReqDTO;
import com.qaml.mes.device.dto.dayoff.DayOffPageReqDTO;
import com.qaml.mes.device.dto.dayoff.DayOffSaveReqDTO;
import com.qaml.mes.device.vo.dayoff.DayOffRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "假期管理")
@RestController
@RequestMapping("/day/off")
public class DayOffController {


    @Autowired
    private DayOffService dayOffService;


    @PostMapping("/save")
    @ApiOperation(value = "假期配置保存修改")
    public OutputMessage<String> saveOrUpdate(@RequestBody @Validated DayOffSaveReqDTO eqpInfoDTO) {
        String id = dayOffService.saveOrUpdate(eqpInfoDTO);
        OutputMessage<String> success = OutputMessage.success();
        success.setData(id);
        return success;
    }

    @PostMapping("/page/list")
    @ApiOperation(value = "列表")
    public PageResponse<DayOffRespVO> pageList(@RequestBody @Validated DayOffPageReqDTO reqDTO) {
        return dayOffService.pageList(reqDTO);
    }


    @DeleteMapping("/del")
    @ApiOperation(value = "删除")
    public Boolean pageList(@RequestBody @Validated DayOffIdReqDTO reqDTO) {
        return dayOffService.deleted(reqDTO);
    }
}
